const DB = wx.cloud.database().collection("aid_knowledge")
const DB_smooth = wx.cloud.database().collection("aid_smooth")
// 轮播图设置
const app = getApp()

Page({
  data: {
    aid_knowledge: [],
    smoothData: [],
    imgUrls: [
      'https://6d61-main-wc2xz-1259126940.tcb.qcloud.la/sujin/aid_knowledge/%E8%BE%9F%E8%B0%A3/aid_knowledge_piyao1.jpg?sign=bc02d62029631bc2a3dbb2cb1856523e&t=1585612241',
      'https://6d61-main-wc2xz-1259126940.tcb.qcloud.la/sujin/aid_knowledge/%E8%BE%9F%E8%B0%A3/aid_knowledge_piyao2.jpg?sign=36dd857de677e9d98e0e6f8607bcde1a&t=1585612288',
      'https://6d61-main-wc2xz-1259126940.tcb.qcloud.la/sujin/aid_knowledge/%E8%BE%9F%E8%B0%A3/aid_knowledge_piyao3.jpg?sign=c06480574d0de8253e76da6a93b0b7d1&t=1585612310',

      'https://6d61-main-wc2xz-1259126940.tcb.qcloud.la/sujin/aid_knowledge/%E8%BE%9F%E8%B0%A3/aid_knowledge_piyao4.jpg?sign=73af4a767b1d0b87e08b15dda3c7729f&t=1585612339',

      'https://6d61-main-wc2xz-1259126940.tcb.qcloud.la/sujin/aid_knowledge/%E8%BE%9F%E8%B0%A3/aid_knowledge_piyao5.jpg?sign=e9e03cb7c52f4571fd818c66c5b7fcf9&t=1585612356',

      'https://6d61-main-wc2xz-1259126940.tcb.qcloud.la/sujin/aid_knowledge/%E8%BE%9F%E8%B0%A3/aid_knowledge_piyao6.jpg?sign=09aa486e95563a2d4c738f44aac45175&t=1585612372'
    ],
    //是否显示画板指示点 
    circular: true,
    //选中点的颜色 
    indicatorDots: true,
    //是否竖直 
    vertical: false,
    //是否自动切换 
    autoplay: true,
    //自动切换的间隔
    interval: 3000,
    //滑动动画时长毫秒 
    duration: 1000,
    //所有图片的高度 
    imgheights: [],
    //图片宽度 
    imgwidth: 750,
    //默认 
    current: 0,
  },

// 跳转到详情页
  toKnowledgeDetail(event) {
    console.log("点击获取的数据", event.currentTarget.dataset.item._id)
    wx.navigateTo({
      url: '../../pages/aid_knowledge_detail/aid_knowledge_detail?id=' + event.currentTarget.dataset.item._id,
    })
  },

  onLoad: function (options) {
    console.log(options);
    var that = this;
    //滚动播报连接数据库aid_swiper
    DB_smooth.get({
      success: res => {
        console.log(res.data)
        this.setData({
          smoothData: res.data
        })
      }
    })

    DB.get({
      //如果查询成功的话    
      success: res => {
        console.log(res.data)
        this.setData({
          aid_knowledge: res.data
        })
      }
    })
  },

})
